package com.shanzmoo.db.job.entity.vo;

import com.alibaba.fastjson.JSON;
import com.shanzmoo.db.job.entity.ScheduleJobEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 定时任务信息
 *
 * @author： Gzhao 2020/12/24
 */
@Data
@ApiModel("定时任务信息")
public class ScheduleJobVo {

    @ApiModelProperty(value = "任务ID")
    private Long jobId;

    @ApiModelProperty(value = "spring bean名称")
    private String beanName;

    @ApiModelProperty(value = "方法名")
    private String methodName;

    @ApiModelProperty(value = "参数")
    private String params;

    @ApiModelProperty(value = "cron表达式")
    private String cronExpression;

    @ApiModelProperty(value = "任务状态 0:暂停 1:启动", hidden = true)
    private Boolean status;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "更新时间", hidden = true)
    private LocalDateTime updateTime;

    public static ScheduleJobVo create(ScheduleJobEntity jobEntity) {
        return JSON.parseObject(JSON.toJSONString(jobEntity), ScheduleJobVo.class);
    }
}
